package pers.zb.cloud.web.upms.service;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import pers.zb.cloud.web.upms.entity.SysPermission;
import pers.zb.cloud.web.upms.service.hystrix.PermissionServiceHystrix;
import pers.zb.cloud.web.upms.vo.PermissionVo;

import java.util.List;

@FeignClient(value = "sea-cloud-service-upms", fallback = PermissionServiceHystrix.class)
public interface PermissionService {

	/**
	 * 根据ID获取权限
	 */
	@RequestMapping(value = "/upms/service/permission/{id}",method = RequestMethod.GET)
	SysPermission getPermissionById(@PathVariable("id") Long id);

	/**
	 * 根据父ID获取权限列表
	 *
	 * @param pid 父ID
	 * @param clientId
	 */
	@RequestMapping(value = "/upms/service/permission/list/{pid}",method = RequestMethod.POST)
	List<PermissionVo> getPermissionListByPid(@PathVariable("pid") Long pid, @RequestParam("clientId") String clientId);

	/**
	 * 判断是否具有子节点
	 */
	@RequestMapping(value = "/upms/service/permission/children/have/{id}",method = RequestMethod.POST)
	boolean haveChildrenMenu(@PathVariable("id") Long id);

	/**
	 * 新增权限
	 */
	@RequestMapping(value = "/upms/service/permission",method = RequestMethod.POST)
	void addPermission(@RequestBody SysPermission sysPermission);

	/**
	 * 更新权限
	 */
	@RequestMapping(value = "/upms/service/permission",method = RequestMethod.PUT)
	void updatePermission(@RequestBody SysPermission sysPermission) throws Exception;

	/**
	 * 获取出自身外的其他所有可用的权限
	 * @param id
	 * @param clientId
	 * @return
	 */
	@RequestMapping(value = "/upms/service/permission/notitself/list/{id}/{clientId}",method = RequestMethod.POST)
	List<PermissionVo> getPermissionListByNotItself(@PathVariable("id") Long id, @PathVariable("clientId") String clientId);

	/**
	 * 批量删除权限
	 *
	 * @param permissionIdArrs 权限ID数组
	 */
	@RequestMapping(value = "/upms/service/permission/batch",method = RequestMethod.POST)
    void deletePermission(@RequestParam("permissionId") Long[] permissionIdArrs) throws Exception;
}
